package zhr.chapter13;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Client {
    public static void main(String[] args) throws IOException {
new TCPClient().connect();
    }
    static class  TCPClient{
        private static  final int PORT =7788;
        public void connect() throws IOException {
            Socket client =new Socket(InetAddress.getLocalHost(),PORT);
           //Socket client =new Socket("172.28.37.193",7788);
            InputStream is =client.getInputStream();
            OutputStream bos =client.getOutputStream();

            byte[] buf=new byte[1024];
            int len=is.read(buf);

            bos.write(("向服务端写999wkf").getBytes());

            System.out.println(new String(buf,0,len));
            client.close();
            is.close();
        }
    }
}
